/**
 * 
 */
package com.dfhc.pub.concurrencycontrol;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import com.dfhc.ISystemConstant;
import com.dfhc.util.HttpClientUtil;

/**
 * @author longsebo
 * 发送加锁请求
 */
public class SendRequestThread extends Thread {
	private CountDownLatch waitObj;
	private String guid;
	public SendRequestThread(String guid,CountDownLatch end){
		waitObj = end;
		this.guid = guid;
	}
	@Override
	public void run(){
		System.out.println("enter!");
		try {
			waitObj.await();
			String url="http://127.0.0.1:8080/qb5activiti/testController/lockByGuid";
			Map<String, String> bodyData = new HashMap<String,String>();
			
			bodyData.put(ISystemConstant.JSGUID, guid);
			try {
				HttpClientUtil.post(url, bodyData);
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println("send request fail!");
				return;
			}
			System.out.println("lock Success!");			
			System.out.println("finish!");
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
				
	}
}
